import { createStore } from 'vuex'

export default createStore({
  state: {
    list: [
      {
        title: "吃饭",
        complete: false,
      },
      {
        title: "睡觉",
        complete: false,
      },
      {
        title: "学习",
        complete: true,
      },
    ],
    currTab: "mine"
  },
  getters: {
  },
  mutations: {
    addTodo(state, todo) {
      state.list.push(todo)
    },
    delTodo(state, paylod) {
      state.list.splice(payload, 1)
    },
    /* paylod表示过滤后的未完成的，直接覆盖list即可 */
    clear(state, payload) {
      state.list = payload
    },
    updateDoubanTab(state, tabName) {
      state.currTab = tabName
    }
  },
  actions: {
  },
  modules: {
  }
})
